<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=7"/>
    <title>物资采购与产品整合管理系统</title>
    <link href="${pageContext.request.contextPath }/css/main.css" rel="stylesheet" type="text/css" media="all"/>
    <script src="${pageContext.request.contextPath }/js/jquery-1.4.2.min.js" type="text/javascript"></script>
    <script>
        $(function () {
            $("#queryBtn").click(function () {
                queryForm.action = "${pageContext.request.contextPath}/user/list";
                queryForm.submit();
            });
            var count = ${pageInfo.pages};
            $("#down").click(function () {
                if ($("#pageNo").val() >= count) {
                    alert("已到达末页");
                    return;
                }
                $("#pageNo").val(parseInt($("#pageNo").val()) + 1);
                queryForm.action = "${pageContext.request.contextPath}/user/list";
                queryForm.submit();
            });
            $("#up").click(function () {
                if ($("#pageNo").val() <= 1) {
                    alert("已到达首页");
                    return;
                }
                $("#pageNo").val(parseInt($("#pageNo").val() - 1));
                queryForm.action = "${pageContext.request.contextPath}/user/list";
                queryForm.submit();
            });
            $("#first").click(function () {
                $("#pageNo").val(1);
                queryForm.action = "${pageContext.request.contextPath}/user/list";
                queryForm.submit();
            });
            $("#last").click(function () {
                $("#pageNo").val(count);
                queryForm.action = "${pageContext.request.contextPath}/user/list";
                queryForm.submit();
            });
            $("#go").click(function () {
                if ($("#pageNo").val() >= count || $("#pageNo").val() <= 1) {
                    alert("输入的页数不正确");
                    return;
                }
                queryForm.action = "${pageContext.request.contextPath}/user/list";
                queryForm.submit();
            });
        })
    </script>
</head>

<body class="content-pages-body">
<div class="content-pages-wrap">
    <div class="commonTitle">
        <h2>&gt;&gt; 用户管理</h2>
    </div>
    <form name="queryForm" method="post">
        <table width="100%" border="0" cellspacing="0" cellpadding="0" class="commonTableSearch">

            <tr>
                <th align="right">用户名：</th>
                <td><input name="LoginName" type="text" class="inputTextNormal" value="${LoginName }" id="textfield1"/>
                </td>
                <th align="right">姓名：</th>
                <td><input name="EName" type="text" value="${EName }" class="inputTextNormal" id="textfield2"/></td>
                <th align="right">
                    <input type="button" id="queryBtn" class="btnShort" value="检索"/>
                </th>
            </tr>

        </table>


        <!--//commonTableSearch-->

        <input type="button" class="btnNormal" value="新增用户"
               onclick="location.href='${pageContext.request.contextPath }/emp/add'"/>

        <br>

        <table width="101%" border="0" cellpadding="0" cellspacing="1" class="commonTable">
            <tr>
                <th>序号</th>
                <th>用户姓名</th>
                <th>用户名</th>
                <th>最近登录时间</th>
                <th class="editColDefault">操作</th>
        </tr>
        <c:forEach items="${pageInfo.list }" var="user">
            <tr>
                <td align="center">${user.userid }</td>
                <td align="center">${user.sysEmp.name }</td>
                <td align="center">${user.loginname }</td>
                <td align="center"><fmt:formatDate value="${user.logintime }" pattern="yyyy-MM-dd HH:mm:ss"/></td>
                <td align="center">
                    <a href="${pageContext.request.contextPath }/user/edit?userid=${user.userid}" class="btnIconEdit"
                       title="更新"></a>
                    <a href="${pageContext.request.contextPath }/user/delete?userid=${user.userid}" class="btnIconDel"
                       title="删除"></a>
                </td>
            </tr>
        </c:forEach>

    </table>
        <!--//commonTable-->
        <div id="pagelist">
            <ul class="clearfix">
                <li><a href="#" id="first">首页</a></li>
                <li><a href="#" id="up">上页</a></li>
                <li><a href="#" id="down">下页</a></li>
                <li class="current"><input type="text" id="pageNo" name="pageNum" value="${pageNum }"
                                           style="text-align:right" size="1"></li>
                <li><a href="#" id="go">跳转</a></li>
                <li><a href="#" id="last">尾页</a></li>
                <li class="pageinfo">第${pageNum }页</li>
                <li class="pageinfo">共${pageInfo.pages }页</li>
            </ul>
        </div>
    </form>
</div>
<!--//content pages wrap-->
</body>
</html>
